package com.zengzhuo.mutithread.basic.create;

import com.zengzhuo.core.utils.ThreadUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TODO
 *
 * @author zhuo.zeng
 * @version 1.0
 * @date 2021/9/30 8:53
 */
public class CreateDemo1352 {

    private static Logger logger = LoggerFactory.getLogger(CreateDemo2.class);
    public static final int MAX_TURN = 5;
    static int threadNo = 1;

    public static void main(String[] args) {
        Thread thread = null;

        //方法2.1：使用实现Runnable的实现类创建和启动线程

        for (int i = 0; i < 2; i++) {
            Runnable target = new CreateDemo2.RunTarget();
            thread = new Thread( () -> {
                    for (int j = 1; j < MAX_TURN; j++) {
                        logger.info(ThreadUtil.getCurThreadName() + ", 轮次：" + j);
                    }
                    logger.info(ThreadUtil.getCurThreadName() + " 运行结束.");

            }, "RunnableThread" + threadNo++);
            thread.start();
        }
    }
}
